/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package MidiGui;

import java.awt.Component;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Image;
import java.awt.Toolkit;
import javax.swing.*;
import javax.swing.JTabbedPane;
import music.global.CharacterMap;

/**
 *
 * @author TJ
 */
public class NoteSelector extends JDialog{
    //private Note selectedNote;
    
    public JTabbedPane tabs;
    public NoteSelector(JFrame f) {
        super(f,false);
        tabs=new JTabbedPane();
        this.setDefaultCloseOperation(JFrame.HIDE_ON_CLOSE);
        NotesPane();
        this.add(tabs);
        this.setSize(300,300);
        this.setVisible(true);
    }
    private void addGB(JPanel c, JComponent c2,int x, int y, int w, int h){
        GridBagConstraints gbc=new GridBagConstraints();
        gbc.gridheight=h;
        gbc.gridwidth=w;
        gbc.gridx=x;
        gbc.gridy=y;
        gbc.fill=GridBagConstraints.BOTH;
        c.add(c2,gbc);
    }
    private void NotesPane() {
        JPanel p=new JPanel();
        p.setLayout(new GridBagLayout());
        AbstractButton[] buts=new AbstractButton[14];
        buts[0]=new JToggleButton(""+(char)CharacterMap.QUARTER_REST+" "+(char)CharacterMap.EIGTH_REST);
        buts[1]=new JToggleButton(""+(char)CharacterMap.STACCATO);
        buts[2]=new JToggleButton(""+(char)CharacterMap._32_NOTE);
        buts[3]=new JToggleButton(""+(char)CharacterMap.SIXTEENTH_NOTE);
        buts[4]=new JToggleButton(""+(char)CharacterMap.EIGTH_NOTE);
        buts[5]=new JToggleButton(""+(char)CharacterMap.QUARTER_NOTE);
        buts[6]=new JToggleButton(""+(char)CharacterMap.HALF_NOTE);
        buts[7]=new JToggleButton(""+(char)CharacterMap.EIGTH_NOTE);
        buts[8]=new JToggleButton(""+(char)CharacterMap.NATURAL);
        buts[9]=new JToggleButton(""+(char)CharacterMap.SHARP);
        buts[10]=new JToggleButton(""+(char)CharacterMap.FLAT);
        buts[11]=new JToggleButton("");
        buts[11].setEnabled(false);
        buts[12]=new JToggleButton(""+(char)CharacterMap.ACCENT);
        buts[13]=new JToggleButton(""+(char)CharacterMap.LEGATO);
        //buts[14]=new JToggleButton(""+CharacterMap.STACCATO);
        for(AbstractButton b : buts){
            //b.setFont(MusicFonts.getFont("OpusRegular").deriveFont(20f));
            Image i=CharacterMap.getImage(MusicFonts.getFont("OpusRegular").deriveFont(20f), b.getText());
            if(i!=null)b.setIcon(new ImageIcon(i));
            b.setText("");
        }
        addGB(p,buts[0],0,5,2,1);
        addGB(p,buts[1],2,5,1,1);
        for(int i=2;i<buts.length;i++) {
            addGB(p,buts[i],(i-2)%3,5-((i-2)/3+1),1,1);
        }
        tabs.setFont(MusicFonts.getFont("OpusRegular").deriveFont(15f));
        tabs.addTab(""+CharacterMap.WHOLE_NOTE, p);
    }
}
